package com.bienvenue.main.ui.fragment.enterprise;

import android.content.Intent;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.bienvenue.main.R;
import com.bienvenue.main.adapter.EnterpriseMainAdapter;
import com.bienvenue.main.base.BaseFragment;
import com.bienvenue.main.loader.ImageBannerLoader;
import com.bienvenue.main.model.EnterpriseMainBean;

import com.bienvenue.main.ui.activity.personal.PersonalDetailsActivity;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.youth.banner.Banner;
import com.youth.banner.BannerConfig;
import com.youth.banner.Transformer;
import com.youth.banner.listener.OnBannerListener;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @ProjectName: Bienvenue
 * @Package: com.bienvenue.main.ui.fragment
 * @ClassName: EnterpriseMainFragment
 * @Description:
 * @Author: Mr.Chen
 * @CreateDate: 2020/9/15 14:48
 * @UpdateUser: Mr.Chen
 * @UpdateDate: 2020/9/15 14:48
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */


public class  EnterpriseMainFragment extends BaseFragment implements OnBannerListener {
    @BindView(R.id.rv_people)
    RecyclerView rvPeople;
    @BindView(R.id.tv_work_experience)
    TextView tvWorkExperience;
    @BindView(R.id.tv_education)
    TextView tvEducation;
    @BindView(R.id.tv_expected_salary)
    TextView tvExpectedSalary;
    @BindView(R.id.banner)
    Banner banner;

    EnterpriseMainAdapter mAdapter;
    @Override
    protected void initData() {
        List<EnterpriseMainBean> list=new ArrayList<>();
        EnterpriseMainBean bean=new EnterpriseMainBean();
        bean.setDetails("某某某 | 女 | 20岁 | 10年经验 | 大专");
        bean.setDreamMoney("期望薪资：8-9K");
        bean.setDreamPosition("期望职位：IT程序猿");

        EnterpriseMainBean bean1=new EnterpriseMainBean();
        bean1.setDetails("某某某 | 女 | 20岁 | 10年经验 | 大专");
        bean1.setDreamMoney("期望薪资：8-9K");
        bean1.setDreamPosition("期望职位：IT程序猿");

        list.add(bean);
        list.add(bean1);
        mAdapter.setNewData(list);

        mAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
            @Override
            public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
                switch (view.getId()){
                    case R.id.tv_select_resume:
                      startActivity(new Intent(getActivity(), PersonalDetailsActivity.class));
                        break;
                    case R.id.cl_resume:
                        showToast("此功能暂未实现");
                        break;
                }
            }
        });

    }

    @Override
    protected void initView(View view) {
        rvPeople.setLayoutManager(new LinearLayoutManager(getContext()));
        mAdapter=new EnterpriseMainAdapter();
        rvPeople.setAdapter(mAdapter);
        List<Integer> imgList = new ArrayList<>();
        imgList.add(R.mipmap.icon_enterprise_banner);
        imgList.add(R.mipmap.icon_enterprise_banner);
        imgList.add(R.mipmap.icon_enterprise_banner);
        List<String> titles = new ArrayList<>();
        titles.add("迎聘招聘1");
        titles.add("迎聘招聘2");
        titles.add("迎聘招聘3");


        banner.setOnBannerListener(this);
        //设置banner样式
        banner.setBannerStyle(BannerConfig.NOT_INDICATOR);
        //设置图片加载器
        banner.setImageLoader(new ImageBannerLoader(getContext()));
        //设置图片集合
        banner.setImages(imgList);
        //设置banner动画效果
        banner.setBannerAnimation(Transformer.Default);
        //设置标题集合（当banner样式有显示title时）
        banner.setBannerTitles(titles);
        //设置自动轮播，默认为true
        banner.isAutoPlay(true);
        //设置轮播时间
        banner.setDelayTime(1500);
        //设置指示器位置（当banner模式中有指示器时）
        banner.setIndicatorGravity(BannerConfig.CENTER);
        //banner设置方法全部调用完毕时最后调用
        banner.start();

    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_enterprise_main;
    }

    @Override
    public void OnBannerClick(int position) {
        showToast("此功能暂未实现");
    }
    @OnClick(R.id.tv_work_experience)
    void onWorkExperience(){
        showToast("此功能暂未实现");
    }
    @OnClick(R.id.tv_education)
    void onEducation(){
        showToast("此功能暂未实现");
    }
    @OnClick(R.id.tv_expected_salary)
    void onExpectedSalary(){
        showToast("此功能暂未实现");
    }
    @OnClick(R.id.iv_more)
    void onMore(){
        showToast("此功能暂未实现");

    }
}
